import { postAction } from "@/api/manage";
import { ref } from "vue";
//表单提交封装函数
export function getSubmitDict() {
    const dialogVisible = ref(false);

    const submitDict = (formEl, URL, form) => {
        alert("submitDict");
        if (!formEl || !formEl.value) return;
        formEl.value.validate((valid) => {
            if (valid) {
                postAction(URL, form.value)
                    .then((res) => {
                        handleClose(form);
                    })
                    .catch((err) => {});
            } else {
                return false;
            }
        });
    };
    //关闭弹窗并重置表单数据
    const handleClose = (form) => {
        dialogVisible.value = false;
        form.value = {
            state: 1,
        };
    };

    return submitDict;
}
